using System.Collections.Generic;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;

namespace Misc
{
	public class XList
	{
		private IList<XListItem> _items;

		public XList()
		{
			_items = new List<XListItem>();
		}
	}

	public class XListItem : Control
	{
		public bool Selected { get; set; }
		public bool Disabled { get; set; }
		public string Text { get; set; }
		public string Value { get; set; }
		public string Group { get; set; }

		public XListItem()
		{
		}

		public XListItem(ListItem item)
		{
			Selected = item.Selected;
			Text = item.Text;
			Value = item.Value;
		}

		public Control RenderControl()
		{
			var control = new HtmlGenericControl(HtmlTextWriterTag.Option.ToString().ToLower()) { InnerText = Text };

			if(Selected)
			{
				control.Attributes.Add("selected", "selected");
			}

			if (Disabled)
			{
				control.Attributes.Add("disabled", "disabled");
			}

			control.Attributes.Add("value", Value);

			return control;
		}
	}
}